package com.credithc.customers.api.service.impl;

import com.credithc.customers.api.service.RedisService;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.concurrent.TimeUnit;

/**
 * @Title:
 * @Author: Denghx
 * @Date: 2020/3/9 23:01
 * @Description: com.credithc.customers.api.service.impl
 * @Version: V1.0.0
 */
@Service("redisService")
public class RedisServiceImpl implements RedisService {
    @Resource
    private RedisTemplate redisTemplate;
    @Override
    public void setObj(final String key, Object obj, long timeout) {
        ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
        operations.set(key, obj, timeout, TimeUnit.SECONDS);
    }
    @Override
    public Object getObj(final String key) {
        Object o = redisTemplate.opsForValue().get(key);
        return o;
    }


}
